Swap
Swap NumericVar1, NumericVar2
 
Parameters:

    NumericVar1 = first numeric variable
    NumericVar2 = second numeric variable
Returns: NONE
 

      Swap swaps the values of two numeric variables. If the data type of both variables are not the same PlayBASIC will cast them automatically.




FACTS:


      * Swap does not support string variables.

      * Swap exchanges the contents of two variables, so it's short hand for the following.

  
; Do swap
  Temp=A    ; Store A in a temp varibale
  A=B  ; Move the value in B into A Variable
  B=Temp   ; Move the Temp Variable into Temp
  


is the same as,

  
; Do swap
  Swap A,B
  







Mini Tutorial:


      In this example we'll define two variables called A and B. These variable will then be displayed on the screen both before and after they're swapped.

  
; define two variables
  a = 12
  b = 3
  
; print the variables
  Print a
  Print b
  
; swap the variables
  Swap a,b
  
; Print the variables
  Print a
  Print b
  
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  12
  3
  3
  12
  

 
Related Info: Float | IF | Integer | SwapIfHigher | SwapIfLower | Variables :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com